Skip to content

Optimize DTS calculation to fix linear access slowdown#22

Open
Asd-g wants to merge 1 commit intovimeo:masterfrom
HomeOfAviSynthPlusEvolution:linear_seeking
Open

Optimize DTS calculation to fix linear access slowdown#22
Asd-g wants to merge 1 commit intovimeo:masterfrom
HomeOfAviSynthPlusEvolution:linear_seeking

Conversation

@Asd-g
Copy link

@Asd-g Asd-g commented Jul 5, 2025

Problem:
When reading a file with B-frames, the decoding order is non-sequential. This caused isom_get_dts_from_info_list to repeatedly scan the entire sample list from the beginning, leading to a performance slowdown that worsened as the video progressed.

Solution:
Cache the last accessed sample number and its DTS. When the next requested sample is forward in the timeline, start the DTS calculation from the cached position instead of from the start. This changes the operation from O(N) to O(N-M) for forward seeks.

@dwbuiten
Copy link
Collaborator

The concept itself seems OK, it just needs to be fixed to use the correct L-SMASH coding style (e.g. for spacing), and then I'll run it through tests.

Problem:
When reading a file with B-frames, the decoding order is non-sequential.
This caused `isom_get_dts_from_info_list` to repeatedly scan the entire
sample list from the beginning, leading to a performance slowdown that
worsened as the video progressed.

Solution:
Cache the last accessed sample number and its DTS. When the next
requested sample is forward in the timeline, start the DTS calculation
from the cached position instead of from the start. This changes the
operation from O(N) to O(N-M) for forward seeks.
@Asd-g
Copy link
Author

Asd-g commented Dec 1, 2025

Pushed with corrected syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants